package com.ruoyi.web.controller.project;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.ProjectTemplateBind;
import com.ruoyi.project.service.IProjectTemplateBindService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目模板绑定Controller
 * 
 * @author ruoyi
 * @date 2025-08-05
 */
@RestController
@RequestMapping("/project/bind")
@Api(tags = "项目模板绑定管理")
public class ProjectTemplateBindController extends BaseController
{
    @Autowired
    private IProjectTemplateBindService projectTemplateBindService;

    /**
     * 查询项目模板绑定列表
     */
    @PreAuthorize("@ss.hasPermi('project:bind:list')")
    @GetMapping("/list")
    @ApiOperation("查询绑定项目分类列表")
    public TableDataInfo list(@ApiParam("绑定项目分类查询条件")ProjectTemplateBind projectTemplateBind)
    {
        startPage();
        List<ProjectTemplateBind> list = projectTemplateBindService.selectProjectTemplateBindList(projectTemplateBind);
        return getDataTable(list);
    }

    /**
     * 导出项目模板绑定列表
     */
    @PreAuthorize("@ss.hasPermi('project:bind:export')")
    @Log(title = "项目模板绑定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectTemplateBind projectTemplateBind)
    {
        List<ProjectTemplateBind> list = projectTemplateBindService.selectProjectTemplateBindList(projectTemplateBind);
        ExcelUtil<ProjectTemplateBind> util = new ExcelUtil<ProjectTemplateBind>(ProjectTemplateBind.class);
        util.exportExcel(response, list, "项目模板绑定数据");
    }

    /**
     * 获取项目模板绑定详细信息
     */
    @ApiOperation("查询绑定项目分类详情")
    @PreAuthorize("@ss.hasPermi('project:bind:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@ApiParam("绑定项目分类ID")@PathVariable("id") Long id)
    {
        return success(projectTemplateBindService.selectProjectTemplateBindById(id));
    }

    /**
     * 新增项目模板绑定
     */
    @ApiOperation("新增绑定项目分类")
    @PreAuthorize("@ss.hasPermi('project:bind:add')")
    @Log(title = "项目模板绑定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@ApiParam("新增绑定项目分类信息")@RequestBody ProjectTemplateBind projectTemplateBind)
    {
        return toAjax(projectTemplateBindService.insertProjectTemplateBind(projectTemplateBind));
    }

    /**
     * 修改项目模板绑定
     */
    @ApiOperation("修改绑定项目分类")
    @PreAuthorize("@ss.hasPermi('project:bind:edit')")
    @Log(title = "项目模板绑定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@ApiParam("修改绑定项目分类信息")@RequestBody ProjectTemplateBind projectTemplateBind)
    {
        return toAjax(projectTemplateBindService.updateProjectTemplateBind(projectTemplateBind));
    }

    /**
     * 删除项目模板绑定
     */
    @ApiOperation("删除绑定项目分类")
    @PreAuthorize("@ss.hasPermi('project:bind:remove')")
    @Log(title = "项目模板绑定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("绑定项目分类ID数组")@PathVariable Long[] ids)
    {
        return toAjax(projectTemplateBindService.deleteProjectTemplateBindByIds(ids));
    }
}
